layui.use(['element'], function(){
  $ = layui.jquery;
    element = layui.element();  
    $(".layui-tab-close").html(" ");
    //监听导航点击
    element.on('nav(side)', function(elem){
      title = elem.find('cite').text();
      url = elem.find('a').attr('_href');
    $(".layui-nav").find("dd").removeClass("li01");
      elem.addClass("li01");
      for (var i = 0; i <$('.x-iframe').length; i++) {
        if($('.x-iframe').eq(i).attr('src')==url){
          element.tabChange('x-tab', i);            
          return;
        }
        
      };

      res = element.tabAdd('x-tab', {
          title: title//用于演示
          ,content: '<iframe frameborder="0" src="'+url+'" class="x-iframe"></iframe>'
    });  
    
    $(".layui-tab-close").html(" ");  
    element.tabChange('x-tab', $('.layui-tab-title li').length-1);

      $('.layui-tab-title li').eq(0).find('i').remove();
   });
});

